package com.mnb.base.service.impl;

import com.mnb.base.entity.StZqrlB;
import com.mnb.common.utils.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.mnb.base.entity.StZqrlB;

import java.util.Date;
import java.util.List;

import com.mnb.base.mapper.StZqrlBMapper;
import com.mnb.base.service.StZqrlBService;

@Service
public class StZqrlBServiceImpl implements StZqrlBService {

    @Resource
    private StZqrlBMapper stZqrlBMapper;


    @Override
    public R getList(StZqrlB stZqrlB) {
        List<StZqrlB> list = stZqrlBMapper.getList(stZqrlB);
        return R.ok(list);
    }

    @Override
    public R getLineList(StZqrlB stZqrlB) {
        List<StZqrlB> list = stZqrlBMapper.getLineList(stZqrlB);
        return R.ok(list);
    }


    @Override
    public R insert(StZqrlB stZqrlB) {
        StZqrlB count = stZqrlBMapper.selectByPrimaryKey(stZqrlB.getStcd(), stZqrlB.getLnnm(), stZqrlB.getBgtm(), stZqrlB.getPtno());
        if (count != null) {
            return R.fail("该信息已存在");
        }
        stZqrlBMapper.insert(stZqrlB);
        return R.ok();
    }

    @Override
    public R udpate(StZqrlB stZqrlB) {
        stZqrlBMapper.updateByPrimaryKey(stZqrlB);
        return R.ok();
    }

    @Override
    public void deleteByPrimaryKey(String stcd, String lnnm, Date bgtm, Short ptno) {
        stZqrlBMapper.deleteByPrimaryKey(stcd, lnnm, bgtm, ptno);
    }

    @Override
    public R getLastBgtmList(StZqrlB stZqrlB) {
        List<StZqrlB> list = stZqrlBMapper.getLastBgtmList(stZqrlB.getStcd());
        return R.ok(list);
    }
}
